//
//  HWAddressSelectCell.m
//  94hwanGame
//
//  Created by 王治庭 on 2018/11/26.
//  Copyright © 2018 王治庭. All rights reserved.
//

#import "HWAddressSelectCell.h"

@implementation HWAddressSelectCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self setUpViews];
    }
    return self;
}
- (void)setUpViews {
    
    self.name = [UILabel new];
    self.name.text = @"";
    self.name.textColor = UIColorFromRGB(0x333333);
    self.name.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:self.name];
    
    self.phone = [UILabel new];
    self.phone.text = @"";
    self.phone.textColor = UIColorFromRGB(0x333333);
    self.phone.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:self.phone];
    
    self.address = [UILabel new];
    self.address.text = @"";
    self.address.textColor = UIColorFromRGB(0x272A33);
    self.address.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.address];
    
    
    self.edit = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.edit setBackgroundColor:[UIColor whiteColor]];
    [self.edit setTitleColor:UIColorFromRGB(0x272a33) forState:UIControlStateNormal];
    [self.edit setImage:[UIImage imageNamed:@"z_edit"] forState:UIControlStateNormal];
    [self.contentView addSubview:self.edit];
    
    
    
//    self.thrBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    [self.thrBtn setImage:[UIImage imageNamed:@"默认地址"] forState:UIControlStateNormal];
//    [self.contentView addSubview:self.thrBtn];
//
//    self.forBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    [self.forBtn setTitle:@"删除" forState:UIControlStateNormal];
//    [self.contentView addSubview:self.forBtn];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.contentView.mas_top).offset(17.5);
        make.left.mas_equalTo(self.contentView.mas_left).offset(11.5);
        make.height.mas_equalTo(14);
    }];
    
    [self.phone mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.contentView.mas_top).offset(17.5);
        make.left.mas_equalTo(self.name.mas_right).offset(27.5);
        make.height.mas_equalTo(14);
    }];
    
    [self.address mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.name.mas_bottom).offset(11);
        make.left.mas_equalTo(self.contentView.mas_left).offset(11.5);
        make.right.mas_equalTo(self.contentView.mas_right).offset(-21*CFLScaleValue);
        make.height.mas_equalTo(14*CFLScaleValue);
    }];
    
   
    
    [self.edit mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.mas_bottom).offset(-18.5);
        make.right.mas_equalTo(self.mas_right).offset(-10.5);
        make.height.mas_equalTo(11.5);
        make.width.mas_equalTo(10.5);

    }];
    
 
}

- (void)setModel:(HWMallGoogsAddressModel *)model {
    
    _model = model;
    self.name.text = model.consignee;
    self.phone.text = model.mobile;
    self.address.text = [NSString stringWithFormat:@"%@", model.uaddress];
   
   
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
